/*
 * NewJFrame.java
 *
 * Created on 30 August 2007, 22:30
 */

package bibleunicodepad;

import java.awt.Font;
import uk.org.sgj.UnicodeInsertion.InsertMenu;

/**
 *
 * @author  Steffen
 */
public class NewJFrame extends javax.swing.JFrame
{
    private InsertMenu iM;
    
    /** Creates new form NewJFrame */
    public NewJFrame()
    {
        super();
        initComponents();
        
        jTextPane1.setFont(new Font("Ezra SIL", Font.PLAIN, 36));

        //Initialise the combobox with the font family names.
        java.util.Iterator<String> itr = uk.org.sgj.SGJNifty.FontUtils.Fonts.getAllFontsPlusPriority();
        while (itr.hasNext())
        {
            jComboBox1.addItem(itr.next());
        }
        jComboBox1.setSelectedIndex(0);
        iM = new InsertMenu(jMenuBar1);
        iM.registerUnicodeField(jTextPane1);
        iM.registerComponent(this);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents()
    {
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        controlPanel = new javax.swing.JPanel();
        otherControls = new javax.swing.JPanel();
        jComboBox1 = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Bible Unicode Pad - a demo application for the BibleIM input method");
        jScrollPane1.setFont(new java.awt.Font("Gentium", 0, 24));
        jTextPane1.setMinimumSize(new java.awt.Dimension(300, 100));
        jTextPane1.setPreferredSize(new java.awt.Dimension(800, 400));
        jScrollPane1.setViewportView(jTextPane1);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jComboBox1.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                jComboBox1ActionPerformed(evt);
            }
        });

        otherControls.add(jComboBox1);

        controlPanel.add(otherControls);

        jButton1.setText("Launch frame");
        jButton1.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                jButton1ActionPerformed(evt);
            }
        });

        controlPanel.add(jButton1);

        getContentPane().add(controlPanel, java.awt.BorderLayout.NORTH);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    NewJFrameDerived njfd;
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
    {//GEN-HEADEREND:event_jButton1ActionPerformed
        njfd = new NewJFrameDerived();
        iM.registerComponent(njfd);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jComboBox1ActionPerformed
    {//GEN-HEADEREND:event_jComboBox1ActionPerformed
        setOurFont();
    }//GEN-LAST:event_jComboBox1ActionPerformed
    
    NewJFrameDerived njf;        
    private void setOurFont()
    {
        String fName = (String)jComboBox1.getSelectedItem();
        
        jTextPane1.setFont(new Font(fName, Font.PLAIN, 36));
        
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[])
    {
        java.awt.EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                new NewJFrame().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel controlPanel;
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextPane jTextPane1;
    private javax.swing.JPanel otherControls;
    // End of variables declaration//GEN-END:variables
    
}
